Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISH-8302 Virtual Threads Configuration #7198

Merged
merged 11 commits into from
Feb 21, 2025

Conversation

aubi
Copy link
Contributor

@aubi aubi commented Feb 18, 2025

Description

Add configuration of virtual threads for all types of Concurrency -- ManagedExecutorService, ManagedScheduledExecutorService, and ManagedThreadFactory

In all 3 cases, there are 3 ways, how to configure usage of virtual threads:

  1. *Definition with virtual = true. E.g. @ManagedExecutorDefinition(name = "java:app/VirtMES", maxAsync = 10, virtual = true)
  2. asadmin command with --useVirtualThread=true, e.g. create-managed-thread-factory --useVirtualThreads=true --target=domain concurrent/VirtFactory
  3. Specify the same in AdminUI

Testing

I wrote a sample application: https://github.com/aubi/samples/tree/main/jakartaee/concurrency/ConcurrencyVirtual

Compile it using Java 21. Compile this branch of Payara 7, run it and execute these commands in asadmin:

create-managed-thread-factory --useVirtualThreads=true --target=domain concurrent/VirtFactory
create-managed-executor-service --useVirtualThreads=true --target=domain concurrent/VirtMES
create-managed-scheduled-executor-service --useVirtualThreads=true --target=domain concurrent/VirtMSES

create-resource-ref --enabled=true --target=server concurrent/VirtFactory
create-resource-ref --enabled=true --target=server concurrent/VirtMES
create-resource-ref --enabled=true --target=server concurrent/VirtMSES

Then open the link (called All VT Resources Report - simpler in the main page):
localhost:8080/ConcurrencyVirtual-1.0-SNAPSHOT/rest/test/simpler

It creates 9 threads using different configurations. Application and Server-defined use virtual threads, the default ones use platform threads. Feel free to change the settings and observe the effect -- you need to reload the app to propagate the change. Default resources require server restart (they are cached).

The expected output is

ManagedExecutorService
======================
Application Defined ManagedExecutorService with virtual=true
------------------------------------------------------------
Thread '' => virtual

Default ManagedExecutorService (should use platform threads)
------------------------------------------------------------
Thread 'concurrent/__defaultManagedExecutorService-managedThreadFactory-Thread-7' => platform

Server-defined ManagedExecutorService from concurrent/VirtMES (should use virtual threads)
------------------------------------------------------------------------------------------
Thread '' => virtual



ManagedScheduledExecutorService
===============================
Application Defined ManagedScheduledExecutorService with virtual=true
---------------------------------------------------------------------
Thread '' => virtual

Default ManagedScheduledExecutorService (should use platform threads)
---------------------------------------------------------------------
Thread 'concurrent/__defaultManagedScheduledExecutorService-managedThreadFactory-Thread-1' => platform

Server-defined ManagedScheduledExecutorService from concurrent/VirtMSES (should use virtual threads)
----------------------------------------------------------------------------------------------------
Thread '' => virtual



ManagedThreadFactory
====================
Application Defined ManagedThreadFactory with virtual=true
----------------------------------------------------------
Thread '' => virtual

Default ManagedThreadFactory (should use platform threads)
----------------------------------------------------------
Thread 'concurrent/__defaultManagedThreadFactory-Thread-8' => platform

Server-defined ManagedThreadFactory from concurrent/VirtFactory (should use virtual threads)
--------------------------------------------------------------------------------------------
Thread '' => virtual

Testing Performed

Creating MES, MSES, MTF via Admin UI or asadmin commands
Changing settings in Admin UI
Verifying the behaviour in the testing app.

Testing Environment

Linux, Open JDK 21

Documentation

payara/Payara-Documentation#551

aubi added 6 commits February 18, 2025 19:15
Introduce fallback in case a creation of an implementation of a
ManagedExecutorService (virtual or fork&join) fails.
Both AdminUI and command-line asadmin are implemented.
It the configuration specifies to use virtual threads, the new
code uses the respective classes for managed scheduled executor service
and managed thread factory. Managed executor service was already
implemented.
@Pandrex247 Pandrex247 self-requested a review February 19, 2025 09:17
@Pandrex247 Pandrex247 self-requested a review February 19, 2025 09:24
aubi and others added 3 commits February 19, 2025 21:40
Based on Andrew's review suggestion.

Co-authored-by: Andrew Pielage <[email protected]>
Based on Andrew's review suggestion.

Co-authored-by: Andrew Pielage <[email protected]>
Based on Andrew's review suggestion.

Co-authored-by: Andrew Pielage <[email protected]>
@aubi aubi requested a review from Pandrex247 February 19, 2025 20:52
@aubi aubi requested a review from breakponchito February 20, 2025 01:21
Copy link
Member

@Pandrex247 Pandrex247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to cause failures in the Concurrency TCK

[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   VirtualFullTests.testPlatformScheduledExecutor:72->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:146 Output did not contain successful message: SUCCESS ==> expected: <true> but was: <false>
[ERROR]   VirtualFullTests.testPlatformThreadFactory:83->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:146 Output did not contain successful message: SUCCESS ==> expected: <true> but was: <false>
[ERROR]   VirtualFullTests.testVirtualScheduledExecutor:78->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:146 Output did not contain successful message: SUCCESS ==> expected: <true> but was: <false>
[ERROR]   VirtualFullTests.testVirtualThreadFactory:89->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:146 Output did not contain successful message: SUCCESS ==> expected: <true> but was: <false>
[ERROR]   VirtualWebTests.testPlatformScheduledExecutor:66->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:146 Output did not contain successful message: SUCCESS ==> expected: <true> but was: <false>
[ERROR]   VirtualWebTests.testPlatformThreadFactory:77->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:146 Output did not contain successful message: SUCCESS ==> expected: <true> but was: <false>
[ERROR]   VirtualWebTests.testVirtualScheduledExecutor:72->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:146 Output did not contain successful message: SUCCESS ==> expected: <true> but was: <false>
[ERROR]   VirtualWebTests.testVirtualThreadFactory:83->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:146 Output did not contain successful message: SUCCESS ==> expected: <true> but was: <false>
[ERROR] Errors: 
[ERROR]   AnnotationWebTests.testAnnoDefinedContextServiceQualifiers:68->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/AnnotationServlet?testMethod=testAnnoDefinedContextServiceQualifiers
[ERROR]   AnnotationWebTests.testAnnoDefinedManagedExecutorSvcQualifiers:73->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/AnnotationServlet?testMethod=testAnnoDefinedManagedExecutorSvcQualifiers
[ERROR]   AnnotationWebTests.testAnnoDefinedManagedScheduledExecutorSvcQualifers:78->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.IOException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/AnnotationServlet?testMethod=testAnnoDefinedManagedScheduledExecutorSvcQualifers
[ERROR]   AnnotationWebTests.testAnnoDefinedManagedThreadFactoryQualifersWeb:83->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/AnnotationServlet?testMethod=testAnnoDefinedManagedThreadFactoryQualifersWeb
[ERROR]   AnnotationWebTests.testAnnotationDefinesContextService:88->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/AnnotationServlet?testMethod=testAnnotationDefinesContextService
[ERROR]   AnnotationWebTests.testAnnotationDefinesManagedExecutor:93->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/AnnotationServlet?testMethod=testAnnotationDefinesManagedExecutor
[ERROR]   AnnotationWebTests.testAnnotationDefinesManagedScheduledExecutor:98->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/AnnotationServlet?testMethod=testAnnotationDefinesManagedScheduledExecutor
[ERROR]   DeploymentDescriptorFullTests.testDeploymentDescriptorDefinedContextServiceQualifiers:82->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinedContextServiceQualifiers
[ERROR]   DeploymentDescriptorFullTests.testDeploymentDescriptorDefinedManagedExecutorSvcQualifiers:87->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinedManagedExecutorSvcQualifiers
[ERROR]   DeploymentDescriptorFullTests.testDeploymentDescriptorDefinedManagedScheduledExecutorSvcQualifers:92->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinedManagedScheduledExecutorSvcQualifers
[ERROR]   DeploymentDescriptorFullTests.testDeploymentDescriptorDefinedManagedThreadFactoryQualifers:97->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinedManagedThreadFactoryQualifers
[ERROR]   DeploymentDescriptorFullTests.testDeploymentDescriptorDefinesContextService:102->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinesContextService
[ERROR]   DeploymentDescriptorFullTests.testDeploymentDescriptorDefinesManagedExecutor:107->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinesManagedExecutor
[ERROR]   DeploymentDescriptorFullTests.testDeploymentDescriptorDefinesManagedScheduledExecutor:112->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.IOException requesting URL=http://localhost:8080/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinesManagedScheduledExecutor
[ERROR]   DeploymentDescriptorWebTests.testDeploymentDescriptorDefinedContextServiceQualifiers:68->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinedContextServiceQualifiers
[ERROR]   DeploymentDescriptorWebTests.testDeploymentDescriptorDefinedManagedExecutorSvcQualifiers:73->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinedManagedExecutorSvcQualifiers
[ERROR]   DeploymentDescriptorWebTests.testDeploymentDescriptorDefinedManagedScheduledExecutorSvcQualifers:78->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinedManagedScheduledExecutorSvcQualifers
[ERROR]   DeploymentDescriptorWebTests.testDeploymentDescriptorDefinedManagedThreadFactoryQualifers:83->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinedManagedThreadFactoryQualifers
[ERROR]   DeploymentDescriptorWebTests.testDeploymentDescriptorDefinesContextService:88->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinesContextService
[ERROR]   DeploymentDescriptorWebTests.testDeploymentDescriptorDefinesManagedExecutor:93->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.FileNotFoundException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinesManagedExecutor
[ERROR]   DeploymentDescriptorWebTests.testDeploymentDescriptorDefinesManagedScheduledExecutor:98->TestClient.runTest:63->TestClient.assertSuccessfulURLResponse:150 » Runtime Exception: java.io.IOException requesting URL=http://localhost:8080/DeploymentDescriptorTests_web/DeploymentDescriptorServlet?testMethod=testDeploymentDescriptorDefinesManagedScheduledExecutor
[INFO] 
[ERROR] Tests run: 295, Failures: 8, Errors: 21, Skipped: 27

@aubi
Copy link
Contributor Author

aubi commented Feb 20, 2025

@Pandrex247 Fixed, thanks for the test!

@Pandrex247 Pandrex247 self-requested a review February 21, 2025 11:20
@aubi aubi merged commit 922dd27 into payara:Payara7 Feb 21, 2025
1 check passed
@aubi aubi deleted the FISH-8302-virtual-threads-configuration branch February 21, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants